package com.rss.inbound.dao.impl;
// default package
// Generated Jan 10, 2013 11:00:14 PM by Hibernate Tools 3.4.0.CR1

import static org.hibernate.criterion.Example.create;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.transaction.annotation.Transactional;

import com.rss.inbound.beans.Sts;
import com.rss.inbound.dao.StsDAO;

/**
 * Home object for domain model class Sts.
 * @see .Sts
 * @author Hibernate Tools
 */
public class StsDAOImpl extends HibernateDaoSupport implements StsDAO{

	private static final Log log = LogFactory.getLog(StsDAOImpl.class);

	private SessionFactory sessionFactory = getSessionFactory();

/*	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		log.info("checking for existence of session factory... setting through spring config = " + sessionFactory);
		this.sessionFactory = sessionFactory;
	}
*/

	public void persist(Sts transientInstance) {
		log.debug("Persisting Sts instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("Object persisted");
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;
		}
	}

	public void attachDirty(Sts instance) {
		log.debug("attaching dirty Sts instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Sts instance) {
		log.debug("attaching clean Sts instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void delete(Sts persistentInstance) {
		log.debug("deleting Sts instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Sts merge(Sts detachedInstance) {
		log.debug("merging Sts instance");
		try {
			Sts result = (Sts) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public Sts findById(java.lang.Integer id) {
		log.debug("getting Sts instance with id: " + id);
		try {
			Sts instance = (Sts) getHibernateTemplate().get("Sts",
					id);
			if (instance == null) {
				log.debug("get successful, no instance found");
			} else {
				log.debug("get successful, instance found");
			}
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List<Sts> findByExample(Sts instance) {
		log.debug("finding Sts instance by example");
		try {
			List<Sts> results = (List<Sts>) sessionFactory.getCurrentSession()
					.createCriteria("Sts").add(create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}
}
